import { aspects } from '../event/aspects'
import { Vector3 } from '../Math/Vector3'
import {Wall} from '../Object3D/Wall'
import { Material } from '../Material/Material';
const walllist: Array<Wall> = [];
export class drawWall {
    readonly type: string
    wallMaterial: Material
    Materialtype: string
    height:number
    constructor(wallMaterial: Material, Materialtype: string, height:number = 40){ 
        this.type = 'Wall'
        this.wallMaterial = wallMaterial
        this.height = height
        this.Materialtype = Materialtype
    }
    
    // 绘制墙体
    draw() {
        aspects.multipoint(false,(data: any) => { 
        const list = data.pointList
        this.addWall(list)
    })
}
    private addWall(list:Array<Vector3>) {
        const myWall = new Wall('qiang',this.height)
        const myMaterial = this.wallMaterial
        myWall.setWallMaterial(myMaterial, this.Materialtype)
        myWall.buildWallByList(list)
        walllist.push(myWall)
    }
    //移除墙面
    removeWall() {
        for (const Wall of walllist) {
            Wall.delete()
        }
        walllist.splice(0, walllist.length)
        
    }
    //更新墙面纹理
    newWallMaterial(stripeMaterial:Material, materialType: string) {
        for (const Wall of walllist) {
            Wall.replaceWallMaterial(stripeMaterial,materialType)
        }
    }
    // 停止绘制
    stopWall() {
        aspects.stopTwoAspects()
    }
    replaceheight(Height: number) {
        for (const Wall of walllist) {
            Wall.replaceHeight(Height)
        }
    }
}

